package com.liuyu.common.framework.feignclient.api.feign.sentinel;

import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import com.liuyu.common.framework.common.service.cmd.PermitCmd;
import com.liuyu.common.framework.common.service.cmd.UserHisQueryCmd;
import com.liuyu.common.framework.common.service.condition.CodeCondition;
import com.liuyu.common.framework.common.service.condition.TranslateReq;
import com.liuyu.common.framework.common.service.condition.UserExtCondition;
import com.liuyu.common.framework.common.service.vo.UserHisVo;
import com.liuyu.common.framework.feignclient.api.feign.facade.Power3ApiCloudFeignClient;
import com.liuyu.common.framework.power.access.service.vo.AccessCondition;
import com.liuyu.common.framework.power.account.vo.*;
import com.liuyu.common.framework.power.app.vo.*;
import com.liuyu.common.framework.power.batchimport.vo.ImportData;
import com.liuyu.common.framework.power.cmd.*;
import com.liuyu.common.framework.power.commoncode.vo.CommonCodeCondition;
import com.liuyu.common.framework.power.commontype.vo.CommonTypeCond;
import com.liuyu.common.framework.power.commontype.vo.CommonTypeVo;
import com.liuyu.common.framework.power.company.vo.CompanyCondition;
import com.liuyu.common.framework.power.company.vo.CompanyInfoVo;
import com.liuyu.common.framework.power.grade.vo.GradeCondition;
import com.liuyu.common.framework.power.grade.vo.GradeVo;
import com.liuyu.common.framework.power.gradeext.vo.GradeExtCond;
import com.liuyu.common.framework.power.gradeext.vo.GradeExtVo;
import com.liuyu.common.framework.power.gradetask.vo.GradeTaskTreeCond;
import com.liuyu.common.framework.power.menu.vo.MenuCondition;
import com.liuyu.common.framework.power.menu.vo.MenuQueryCmd;
import com.liuyu.common.framework.power.menu.vo.MenuVo;
import com.liuyu.common.framework.power.oauth2.vo.OauthClientCond;
import com.liuyu.common.framework.power.oauth2.vo.OauthClientDetailVo;
import com.liuyu.common.framework.power.taglib.vo.TagDetailTreeVo;
import com.liuyu.common.framework.power.taglib.vo.TaglibCondition;
import com.liuyu.common.framework.power.task.vo.TaskCodeResult;
import com.liuyu.common.framework.power.task.vo.TaskCondition;
import com.liuyu.common.framework.power.task.vo.TaskVo;
import com.liuyu.common.framework.power.user.vo.UserVo;
import com.liuyu.common.framework.power.usergrade.vo.UserGradeExtendVo;
import com.liuyu.common.framework.power.usergrade.vo.UserGradeVo;
import com.liuyu.common.framework.power.vo.CommonCode;
import com.liuyu.common.framework.power.vo.MsgTemplateCondition;
import com.liuyu.common.framework.power.vo.VueTree;
import com.liuyu.common.framework.utils.Page;
import com.liuyu.common.framework.web.response.ApiResponse;
import lombok.extern.slf4j.Slf4j;
import org.springframework.cloud.openfeign.FallbackFactory;
import org.springframework.stereotype.Service;
import schema.code.model.query.CpsDataDictionaryQuery;
import schema.code.model.query.CpsDataDictionaryTypeQuery;
import schema.code.model.vo.CpsDataDictionaryVO;
import schema.dto.*;

import java.io.IOException;
import java.util.List;
import java.util.Map;

/**
 * sentinel 熔断降级服务
 *
 * @ClassName power3CloudFallbackFactory
 * @Description: TODO
 * @Author: liuyu
 * @Date: Created in 2020/5/12 16:42
 * @Version: 1
 * @Modified By:
 */
@Service
@Slf4j
public class Power3ApiCloudSentinelFallback implements FallbackFactory<Power3ApiCloudFeignClient> {


    /**
     * @param throwable
     * @return
     */
    @Override
    public Power3ApiCloudFeignClient create(Throwable throwable) {
        log.error(throwable.getMessage(), throwable);
        return new Power3ApiCloudFeignClient() {

            @Override
            public ApiResponse queryAccess(AccessCondition accessCondition) {
                log.error("服务熔断");
                return ApiResponse.fail("服务熔断");
            }

            @Override
            public ApiResponse getAccess(IdCmd idCmd) {
                log.error("服务熔断");
                return ApiResponse.fail("服务熔断");
            }

            @Override
            public ApiResponse saveAccess(CpsAccessDTO access) {
                log.error("服务熔断");
                return ApiResponse.fail("服务熔断");
            }

            @Override
            public ApiResponse<CpsUserMainDTO> prepareQueryAccount(String userCode) throws Exception {
                log.error("服务熔断");
                return ApiResponse.fail("服务熔断");
            }

            @Override
            public ApiResponse<Page<AccountVo>> queryUserAccount(UserAccountCond userAccountCond) throws IOException {
                log.error("服务熔断");
                return ApiResponse.fail("服务熔断");
            }

            @Override
            public ApiResponse<UserAccountVo> prepareAddUserAccount(IdCmd idCmd) {
                log.error("服务熔断");
                return ApiResponse.fail("服务熔断");
            }

            @Override
            public ApiResponse<VueTree> getAccountSystem(QueryByUserCmd userCmd) {
                log.error("服务熔断");
                return ApiResponse.fail("服务熔断");
            }

            @Override
            public ApiResponse<UserAccountVo> saveAccount(UserAccountVo account) throws Exception {
                log.error("服务熔断");
                return ApiResponse.fail("服务熔断");
            }

            @Override
            public ApiResponse<Boolean> saveAccountAppKey(AccountAppKeyCmd appKeyCmd) throws IOException {
                log.error("服务熔断");
                return ApiResponse.fail("服务熔断");
            }

            @Override
            public ApiResponse<Boolean> checkOldPwd(PassWordVo password) throws IOException {
                log.error("服务熔断");
                return ApiResponse.fail("服务熔断");
            }

            @Override
            public ApiResponse active(String validataCode) {
                log.error("服务熔断");
                return ApiResponse.fail("服务熔断");
            }

            @Override
            public ApiResponse activeDirect(ActiveCmd activeCmd) {
                log.error("服务熔断");
                return ApiResponse.fail("服务熔断");
            }

            @Override
            public ApiResponse weakPasswordScan(WeakPasswordScanCmd weakPasswordScanCmd) {
                log.error("服务熔断");
                return ApiResponse.fail("服务熔断");
            }

            @Override
            public ApiResponse prepareChangePwd(String appKey) {
                log.error("服务熔断");
                return ApiResponse.fail("服务熔断");
            }

            @Override
            public ApiResponse sendChpEmail(EmailCmd email) {
                log.error("服务熔断");
                return ApiResponse.fail("服务熔断");
            }

            @Override
            public ApiResponse sendChpMobile(EmailCmd emailCmd) {
                log.error("服务熔断");
                return ApiResponse.fail("服务熔断");
            }

            @Override
            public ApiResponse forgetpwdself(FindAccountCmd findAccountCmd) {
                log.error("服务熔断");
                return ApiResponse.fail("服务熔断");
            }

            @Override
            public ApiResponse doPasswordReset(FindAccountCmd findAccountCmd) {
                log.error("服务熔断");
                return ApiResponse.fail("服务熔断");
            }

            @Override
            public ApiResponse<Page<AppVo>> queryApplication(AppCondition appCondition) {
                log.error("服务熔断");
                return ApiResponse.fail("服务熔断");
            }

            @Override
            public ApiResponse prepareApplicationForEdit(IdCmd idCmd) {
                log.error("服务熔断");
                return ApiResponse.fail("服务熔断");
            }

            @Override
            public ApiResponse saveApplication(AppInfoVo application) {
                log.error("服务熔断");
                return ApiResponse.fail("服务熔断");
            }

            @Override
            public ApiResponse<Boolean> checkAppKey(AppCmd appCmd) throws IOException {
                log.error("服务熔断");
                return ApiResponse.fail("服务熔断");
            }

            @Override
            public ApiResponse<AppSettingVo> appSettingDetail(AppCmd appCmd) {
                log.error("服务熔断");
                return ApiResponse.fail("服务熔断");
            }

            @Override
            public ApiResponse<Integer> saveAppSetting(CpsAppConfDTO appSetting) {
                log.error("服务熔断");
                return ApiResponse.fail("服务熔断");
            }

            @Override
            public ApiResponse<Page> queryAppGradeConfig(AppGradeConfCond appCondition) {
                log.error("服务熔断");
                return ApiResponse.fail("服务熔断");
            }

            @Override
            public ApiResponse saveAppGradeConf(AppGradeConfVo appGradeConfVo) throws IOException {
                log.error("服务熔断");
                return ApiResponse.fail("服务熔断");
            }

            @Override
            public ApiResponse<VueTree> getAppGradeTree(GradeTreeCmd gradeTreeCmd) throws IOException {
                log.error("服务熔断");
                return ApiResponse.fail("服务熔断");
            }

            @Override
            public ApiResponse saveAppGrade(AppGradeVo appGradeVo) {
                log.error("服务熔断");
                return ApiResponse.fail("服务熔断");
            }

            @Override
            public ApiResponse changePwd(SecurityCmd securityCmd) {
                log.error("服务熔断");
                return ApiResponse.fail("服务熔断");
            }

            @Override
            public ApiResponse checkPwdMeter(SecurityCmd securityCmd) {
                log.error("服务熔断");
                return ApiResponse.fail("服务熔断");
            }

            @Override
            public ApiResponse checkOldPwd(SecurityCmd securityCmd) {
                log.error("服务熔断");
                return ApiResponse.fail("服务熔断");
            }

            @Override
            public ApiResponse changePassWord(SecurityCmd securityCmd) {
                log.error("服务熔断");
                return ApiResponse.fail("服务熔断");
            }

            @Override
            public ApiResponse accountActive(String validataCode) {
                log.error("服务熔断");
                return ApiResponse.fail("服务熔断");
            }

            @Override
            public ApiResponse prepareChangePassword(String userCode) {
                log.error("服务熔断");
                return ApiResponse.fail("服务熔断");
            }

            @Override
            public ApiResponse changePassWordSelf(SecurityCmd securityCmd) {
                log.error("服务熔断");
                return ApiResponse.fail("服务熔断");
            }

            @Override
            public ApiResponse phone(SecurityCmd securityCmd) {
                log.error("服务熔断");
                return ApiResponse.fail("服务熔断");
            }

            @Override
            public ApiResponse phoneValidataCode(SecurityCmd securityCmd) {
                log.error("服务熔断");
                return ApiResponse.fail("服务熔断");
            }

            @Override
            public ApiResponse<Page<CommonCode>> getCode(CodeCondition codeCondition) {
                log.error("服务熔断");
                return ApiResponse.fail("服务熔断");
            }

            @Override
            public ApiResponse translateCode(TranslateReq translateReq) throws IOException {
                log.error("服务熔断");
                return ApiResponse.fail("服务熔断");
            }

            @Override
            public ApiResponse prepareCommonCodeForEdit(IdCmd idCmd) {
                log.error("服务熔断");
                return ApiResponse.fail("服务熔断");
            }

            @Override
            public ApiResponse queryCommonCode(CommonCodeCondition commonCodeCondition) {
                log.error("服务熔断");
                return ApiResponse.fail("服务熔断");
            }

            @Override
            public ApiResponse saveCommonCode(CpsCommonCodeDTO commonCode) {
                log.error("服务熔断");
                return ApiResponse.fail("服务熔断");
            }

            @Override
            public ApiResponse<CommonTypeVo> commonTypeDetail(IdCmd idCmd) {
                log.error("服务熔断");
                return ApiResponse.fail("服务熔断");
            }

            @Override
            public ApiResponse<Page<CommonTypeVo>> commonTypeList(CommonTypeCond commonTypeCond) {
                log.error("服务熔断");
                return ApiResponse.fail("服务熔断");
            }

            @Override
            public ApiResponse saveCommonType(CommonTypeVo commonTypeVo) {
                log.error("服务熔断");
                return ApiResponse.fail("服务熔断");
            }

            @Override
            public ApiResponse<Page> queryCompany(CompanyCondition companyCondition) throws IOException {
                log.error("服务熔断");
                return ApiResponse.fail("服务熔断");
            }

            @Override
            public ApiResponse checkComCode(ComCmd comCmd) throws IOException {
                log.error("服务熔断");
                return ApiResponse.fail("服务熔断");
            }

            @Override
            public ApiResponse saveCompany(CompanyInfoVo company) {
                log.error("服务熔断");
                return ApiResponse.fail("服务熔断");
            }

            @Override
            public ApiResponse prepareCompanyEdit(ComCmd comCmd) {
                log.error("服务熔断");
                return ApiResponse.fail("服务熔断");
            }

            @Override
            public ApiResponse saveDataDictionaryType(CpsDataDictionaryTypeDTO dataDictionaryType) {
                log.error("服务熔断");
                return ApiResponse.fail("服务熔断");
            }

            @Override
            public ApiResponse listDataDictionaryType(CpsDataDictionaryTypeQuery dictionaryTypeQuery) {
                log.error("服务熔断");
                return ApiResponse.fail("服务熔断");
            }

            @Override
            public ApiResponse saveDataDictionary(CpsDataDictionaryVO dataDictionary) {
                log.error("服务熔断");
                return ApiResponse.fail("服务熔断");
            }

            @Override
            public ApiResponse listDataDictionary(CpsDataDictionaryQuery dictionaryTypeQuery) {
                log.error("服务熔断");
                return ApiResponse.fail("服务熔断");
            }

            @Override
            public ApiResponse prepareMenuForEdit(IdCmd idCmd) {
                log.error("服务熔断");
                return ApiResponse.fail("服务熔断");
            }

            @Override
            public ApiResponse<Page> queryMenu(MenuCondition menuCondition) {
                log.error("服务熔断");
                return ApiResponse.fail("服务熔断");
            }

            @Override
            public ApiResponse saveMenu(MenuVo menu) {
                log.error("服务熔断");
                return ApiResponse.fail("服务熔断");
            }

            @Override
            public ApiResponse showMenu(ShowMenuCmd showMenuCmd) {
                log.error("服务熔断");
                return ApiResponse.fail("服务熔断");
            }

            @Override
            public ApiResponse saveClientDetails(OauthClientDetailVo oauthClientDetailVo) {
                log.error("服务熔断");
                return ApiResponse.fail("服务熔断");
            }

            @Override
            public ApiResponse clientDetails(OauthClientCmd oauthClientCmd) {
                log.error("服务熔断");
                return ApiResponse.fail("服务熔断");
            }

            @Override
            public ApiResponse<Page> queryClientDetails(OauthClientCond oauthClientCond) {
                log.error("服务熔断");
                return ApiResponse.fail("服务熔断");
            }

            @Override
            public ApiResponse saveTaglib(CpsTagLibDTO taglib) {
                log.error("服务熔断");
                return ApiResponse.fail("服务熔断");
            }

            @Override
            public ApiResponse queryTaglib(TaglibCondition taglibCondition) {
                log.error("服务熔断");
                return ApiResponse.fail("服务熔断");
            }

            @Override
            public ApiResponse<List<TagDetailTreeVo>> getTagDetailTree(TagDetailTreeCmd tagDetailTreeCmd) {
                log.error("服务熔断");
                return ApiResponse.fail("服务熔断");
            }

            @Override
            public ApiResponse<CpsTagLibDetailDTO> getTagDetail(Integer id) {
                log.error("服务熔断");
                return ApiResponse.fail("服务熔断");
            }

            @Override
            public ApiResponse saveTagDetail(CpsTagLibDetailDTO detail) {
                log.error("服务熔断");
                return ApiResponse.fail("服务熔断");
            }

            @Override
            public ApiResponse deleteTaglib(IdCmd idCmd) {
                log.error("服务熔断");
                return ApiResponse.fail("服务熔断");
            }

            @Override
            public ApiResponse getTagLib(IdCmd idCmd) {
                log.error("服务熔断");
                return ApiResponse.fail("服务熔断");
            }

            @Override
            public ApiResponse initTag(TagDetailCmd tagDetailCmd) {
                log.error("服务熔断");
                return ApiResponse.fail("服务熔断");
            }

            @Override
            public ApiResponse deleteTagDetail(IdCmd idCmd) {
                log.error("服务熔断");
                return ApiResponse.fail("服务熔断");
            }

            @Override
            public ApiResponse<TaskVo> prepareAddTask(IdCmd idCmd) {
                log.error("服务熔断");
                return ApiResponse.fail("服务熔断");
            }

            @Override
            public ApiResponse saveTask(TaskVo task) {
                log.error("服务熔断");
                return ApiResponse.fail("服务熔断");
            }

            @Override
            public ApiResponse deleteTask(IdCmd idCmd) throws IOException {
                log.error("服务熔断");
                return ApiResponse.fail("服务熔断");
            }

            @Override
            public ApiResponse<Boolean> checkTaskCode(String taskCode) throws IOException {
                log.error("服务熔断");
                return ApiResponse.fail("服务熔断");
            }

            @Override
            public ApiResponse<Page<TaskCodeResult>> queryTask(TaskCondition taskCondition) throws IOException {
                log.error("服务熔断");
                return ApiResponse.fail("服务熔断");
            }

            @Override
            public ApiResponse queryMsgTemplate(MsgTemplateCondition msgTemplateCondition) {
                log.error("服务熔断");
                return ApiResponse.fail("服务熔断");
            }

            @Override
            public ApiResponse prepareMsgTemplateForEdit(IdCmd idCmd) {
                log.error("服务熔断");
                return ApiResponse.fail("服务熔断");
            }

            @Override
            public ApiResponse saveMsgTemplate(CpsMsgTemplateDTO msgTemplate) {
                log.error("服务熔断");
                return ApiResponse.fail("服务熔断");
            }

            @Override
            public ApiResponse saveMsgContent(MsgContentCmd msgContentCmd) {
                log.error("服务熔断");
                return ApiResponse.fail("服务熔断");
            }

            @Override
            public ApiResponse<UserVo> getUser(UserCmd userCmd) {
                log.error("服务熔断");
                return ApiResponse.fail("服务熔断");
            }

            @Override
            public ApiResponse saveUser(UserVo userVo) {
                log.error("服务熔断");
                return ApiResponse.fail("服务熔断");
            }

            @Override
            public ApiResponse<Page> queryUser(UserExtCondition userCondition) {
                log.error("服务熔断");
                return ApiResponse.fail("服务熔断");
            }

            @Override
            public ApiResponse<Boolean> checkUserCode(UserCmd userCmd) {
                log.error("服务熔断");
                return ApiResponse.fail("服务熔断");
            }

            @Override
            public ApiResponse importUserAndPower(ImportData userImport) {
                log.error("服务熔断");
                return ApiResponse.fail("服务熔断");
            }

            @Override
            public ApiResponse<UserGradeVo> getUserGrade(UserCmd userCmd) {
                log.error("服务熔断");
                return ApiResponse.fail("服务熔断");
            }

            @Override
            public ApiResponse<VueTree> getUserGradeTree(UserGradeCmd userGradeCmd) {
                log.error("服务熔断");
                return ApiResponse.fail("服务熔断");
            }

            @Override
            public ApiResponse<UserGradeExtendVo> prepareUserGradeExtend(UserGradeCmd userGradeCmd) {
                log.error("服务熔断");
                return ApiResponse.fail("服务熔断");
            }

            @Override
            public ApiResponse saveUserGrade(UserGradeCmd userGradeCmd) {
                log.error("服务熔断");
                return ApiResponse.fail("服务熔断");
            }

            @Override
            public ApiResponse saveUserGradeExtend(UserGradeExtendVo userGradeExtendVo) {
                log.error("服务熔断");
                return ApiResponse.fail("服务熔断");
            }

            @Override
            public ApiResponse getUrlOrMethod(PermitCmd permitCmd) {
                log.error("服务熔断");
                List<Map<String, Object>> list = Lists.newArrayListWithCapacity(1);
                Map<String, Object> map = Maps.newHashMapWithExpectedSize(2);
                map.put("acce", "/**");
                map.put("perm", "CPS_CenterPowerSystem");
                list.add(map);
                return ApiResponse.success("服务熔断", list);
            }

            @Override
            public ApiResponse getUserHisBySessionId(UserHisQueryCmd userHisQueryCmd) {
                log.error("服务熔断");
                return ApiResponse.fail("服务熔断");
            }

            @Override
            public ApiResponse saveUserLoginHis(UserHisVo loginHis) {
                log.error("服务熔断");
                return ApiResponse.fail("服务熔断");
            }

            @Override
            public ApiResponse<List<CpsMenuDTO>> getMenu(MenuQueryCmd menuQueryCmd) {
                log.error("服务熔断");
                return ApiResponse.fail("服务熔断");
            }

            @Override
            public ApiResponse getGrade(IdCmd idCmd) {
                log.error("服务熔断");
                return ApiResponse.fail("服务熔断");
            }

            @Override
            public ApiResponse getGradeTaskTree(GradeTaskTreeCond gradeTaskTreeCond) {
                log.error("服务熔断");
                return ApiResponse.fail("服务熔断");
            }

            @Override
            public ApiResponse saveGrade(GradeVo grade) {
                log.error("服务熔断");
                return ApiResponse.fail("服务熔断");
            }

            @Override
            public ApiResponse changeGradeTask(GradeTaskTreeCond gradeTaskTreeCond) {
                log.error("服务熔断");
                return ApiResponse.fail("服务熔断");
            }

            @Override
            public ApiResponse queryGradeList(GradeCondition gradeCondition) {
                log.error("服务熔断");
                return ApiResponse.fail("服务熔断");
            }

            @Override
            public ApiResponse saveGradeExt(GradeExtVo gradeExtVo) {
                log.error("服务熔断");
                return ApiResponse.fail("服务熔断");
            }

            @Override
            public ApiResponse queryGradeExtList(GradeExtCond gradeExtCond) {
                log.error("服务熔断");
                return ApiResponse.fail("服务熔断");
            }

            @Override
            public ApiResponse gradeExtDetail(IdCmd idCmd) {
                log.error("服务熔断");
                return ApiResponse.fail("服务熔断");
            }
        };
    }
}
